/*
 * Copyright 2002-2007 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.aop;

import org.aopalliance.intercept.MethodInterceptor;

/**
 * Subinterface of AOP Alliance MethodInterceptor that allows additional interfaces
 * to be implemented by the interceptor, and available via a proxy using that
 * interceptor. This is a fundamental AOP concept called <b>introduction</b>.
 *
 * <p>Introductions are often <b>mixins</b>, enabling the building of composite
 * objects that can achieve many of the goals of multiple inheritance in Java.
 *
 * @author Rod Johnson
 * @see DynamicIntroductionAdvice
 */
/*
1. 总结
IntroductionInterceptor 是 Spring AOP 中用于实现引入（Introduction）功能的核心接口
它同时继承了 MethodInterceptor 和 DynamicIntroductionAdvice，兼具方法拦截和动态接口引入的能力
通过该接口可以为现有的对象动态添加新的接口实现，实现类似多重继承的功能
2. 内部成员说明
	IntroductionInterceptor 是一个标记接口，没有定义任何自己的方法。它继承自以下两个接口：
	MethodInterceptor：提供方法拦截能力，允许在方法调用前后执行自定义逻辑
	DynamicIntroductionAdvice：提供动态接口引入能力，可以通过 boolean implementsInterface(Class<?> intf) 方法判断是否实现了特定接口
3. 类和接口关系
    Advice	AOP 联盟定义的根标记接口，表示通知（增强）的通用概念，不包含任何方法
     ├── Interceptor	标记接口，用于拦截方法调用
     │   ├── ConstructorInterceptor  构造器拦截器，用于拦截构造器调用
     │   └── MethodInterceptor	方法拦截器，可以在方法调用前后执行自定义逻辑
     │      ├── IntroductionInterceptor
     │      │     ├── DelegatePerTargetObjectIntroductionInterceptor
     │  	│     └──  DelegatingIntroductionInterceptor
     │      └── ...
     └── DynamicIntroductionAdvice	动态引入接口，用于向目标对象动态添加新的接口和实现
         └── IntroductionInterceptor 标记接口，用于动态引入新的接口和实现到目标对象
             ├── DelegatePerTargetObjectIntroductionInterceptor	委托引入拦截器，通过委托给特定对象实现引入的接口
         	 └──  DelegatingIntroductionInterceptor

	DynamicIntroductionAdvice：支持运行时动态决定实现哪些接口的引入通知接口
	IntroductionInfo：静态引入接口信息，需要预先知道要引入的所有接口
	IntroductionAdvisor：引入顾问接口，用于指定哪些接口将通过引入通知暴露
	IntroductionInterceptor：引入拦截器，是 DynamicIntroductionAdvice 的具体实现接口

4. 使用场景
	为现有对象动态添加新的接口和实现
	实现 Mixin 模式，构建具有多个父类行为的复合对象
	在不修改原始类的情况下增加新的状态和行为
	实现类似多重继承的功能，弥补 Java 单继承的限制
5. 实际代码应用示例
// 定义要引入的新接口
public interface Lockable {
    void lock();
    void unlock();
    boolean isLocked();
}

// 创建 IntroductionInterceptor 实现
public class LockMixin extends DelegatingIntroductionInterceptor implements Lockable {
    private boolean locked;

    @Override
    public void lock() {
        this.locked = true;
    }

    @Override
    public void unlock() {
        this.locked = false;
    }

    @Override
    public boolean isLocked() {
        return this.locked;
    }

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        if (isLocked() && invocation.getMethod().getName().startsWith("set")) {
            throw new IllegalStateException("Object is locked");
        }
        return super.invoke(invocation);
    }
}

// 应用引入拦截器
ProxyFactory proxyFactory = new ProxyFactory(targetObject);
proxyFactory.addAdvisor(new DefaultIntroductionAdvisor(new LockMixin()));
Lockable lockableObject = (Lockable) proxyFactory.getProxy();


 */
public interface IntroductionInterceptor extends MethodInterceptor, DynamicIntroductionAdvice {

}
